<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of load</title>
  <meta name="keywords" content="load">
  <meta name="description" content="load(g,filename) --- read a saved graph on disk">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html &copy; 2003 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../../index.html">Home</a> &gt;  <a href="../index.html">matgraph</a> &gt; <a href="index.html">@graph</a> &gt; load.m</div>

<!--<table width="100%"><tr><td align="left"><a href="../../index.html"><img alt="<" border="0" src="../../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="index.html">Index for matgraph/@graph&nbsp;<img alt=">" border="0" src="../../right.png"></a></td></tr></table>-->

<h1>load
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>load(g,filename) --- read a saved graph on disk</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>function load(g,filename) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre class="comment"> load(g,filename) --- read a saved graph on disk
 reads in a graph saved by a previous call to save(g,filename)</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../../matlabicon.gif)">
<li><a href="add.html" class="code" title="function add(g,i,j)">add</a>	add --- add edge(s) to the graph</li><li><a href="embed.html" class="code" title="function embed(g,xy)">embed</a>	embed --- create an embedding for a graph</li><li><a href="full.html" class="code" title="function full(g)">full</a>	full(g) --- convert internal storage for g to full</li><li><a href="label.html" class="code" title="function label(g,v,name)">label</a>	Assign labels to vertices of g</li><li><a href="nv.html" class="code" title="function n = nv(g)">nv</a>	nv(g) --- number of vertices in g</li><li><a href="resize.html" class="code" title="function resize(g, n)">resize</a>	resize(g,n) --- change the number of vertices in g to n</li><li><a href="sparse.html" class="code" title="function sparse(g)">sparse</a>	sparse(g) --- convert internal storage for g to sparse</li></ul>
This function is called by:
<ul style="list-style-image:url(../../matlabicon.gif)">
</ul>
<!-- crossreference -->


<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function load(g,filename)</a>
0002 <span class="comment">% load(g,filename) --- read a saved graph on disk</span>
0003 <span class="comment">% reads in a graph saved by a previous call to save(g,filename)</span>
0004 
0005 
0006 fid = fopen(filename,<span class="string">'r'</span>);
0007 
0008 <span class="keyword">if</span> fid == -1
0009     error([<span class="string">'File &quot;'</span>, filename, <span class="string">'&quot; cannot be opened for reading'</span>]);
0010 <span class="keyword">end</span>
0011 
0012 A = textscan(fid,<span class="string">'%s\n'</span>,<span class="string">'whitespace'</span>,<span class="string">'\n'</span>);
0013 A = A{1};
0014 
0015 nl = length(A);
0016 
0017 <span class="keyword">for</span> k=1:nl
0018     line = A{k};
0019     eval(line);
0020 <span class="keyword">end</span>
0021 
0022 <a href="resize.html" class="code" title="function resize(g, n)">resize</a>(g,0);
0023 
0024 <span class="keyword">if</span> (sp == 1)
0025     <a href="sparse.html" class="code" title="function sparse(g)">sparse</a>(g)
0026 <span class="keyword">else</span>
0027     <a href="full.html" class="code" title="function full(g)">full</a>(g)
0028 <span class="keyword">end</span>
0029 
0030 <a href="resize.html" class="code" title="function resize(g, n)">resize</a>(g,nverts);
0031 <a href="add.html" class="code" title="function add(g,i,j)">add</a>(g,elist);
0032 
0033 <span class="keyword">if</span> (length(xy) &gt; 0)
0034     <a href="embed.html" class="code" title="function embed(g,xy)">embed</a>(g,xy);
0035 <span class="keyword">end</span>
0036 
0037 n = <a href="nv.html" class="code" title="function n = nv(g)">nv</a>(g);
0038 
0039 <span class="keyword">if</span> (length(labs)&gt;0)
0040     <span class="keyword">for</span> k=1:n
0041         <a href="label.html" class="code" title="function label(g,v,name)">label</a>(g,k,labs{k});
0042     <span class="keyword">end</span>
0043 <span class="keyword">end</span>
0044 
0045 fclose(fid);</pre></div>
<hr><address>Generated on Fri 30-Apr-2010 07:51:16 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> &copy; 2003</address>
</body>
</html>